package com.sgx.learning.luban.homework.attributes;

import com.sgx.learning.luban.homework.attributes.ext.LocalVariableType;
import com.sgx.learning.luban.homework.basictype.U2;
import com.sgx.learning.luban.homework.constantpool.ConstantPoolInfo;

import java.io.IOException;
import java.io.InputStream;

public class LocalVariableTypeTable extends AttributeInfo {

    private short localVariableTypeTableLength;

    private LocalVariableType[] localVariableTypes;

    @Override
    public void read(InputStream is, ConstantPoolInfo[] constantPoolInfos) throws IOException {
        this.localVariableTypeTableLength = U2.read(is).getValue();
        if(this.localVariableTypeTableLength > 0) {
            this.localVariableTypes = new LocalVariableType[this.localVariableTypeTableLength];
            for (int i = 0; i < this.localVariableTypeTableLength; i++) {
                LocalVariableType temp = new LocalVariableType();
                temp.read(is);
                localVariableTypes[i] = temp;
            }
        }
    }
}
